The complexity of memory management in software systems continues to grow. Modern languages, such as the Java programming language developed by Sun Microsystems, Inc., eliminate some of the burden of memory management by offering automatic “garbage collection” functionality. In languages having garbage collection, a garbage collector object periodically frees all the objects that are no longer needed or can no longer be “reached” by the running program. Ideally, garbage collection will clean up all objects that are no longer needed by the program. Unfortunately, the garbage collector may not free a temporary object, which is created for an operation and then released by its creating object, because another object has created an unknown reference to the temporary object. Because the program is not aware of this unknown reference, it will fail to set this reference to null at the end of the operation. As a result, the garbage collector will not reclaim this temporary object after the operation has finished. This failure to garbage collect objects that are no longer needed results in memory management inefficiencies because the system must continue maintaining created memory for the object, instead of re-allocating the memory space to other objects needing memory resources.
This memory management problem is commonly referred to as a “memory leak.” A memory leak is caused when an object cannot be collected or freed (such that its memory space becomes available for other purposes) because another object is still referring to the object, even though a software program no longer needs the object. As the number of memory leaks increases, the software program may unexpectedly run out of memory after performing a number of operations.
Memory leaks can be difficult to eliminate, because the complexity of most programs prevents manually verifying the validity of every reference. Even after a memory leak has been identified, further analysis will usually be required in order to fully understand the cause and determine the most effective solution to the memory leak. For example, true memory leaks must be distinguished from artifacts like cached objects, which are intentionally retained.
Accordingly, it would be desirable to provide methods for identifying and eliminating memory leaks in Java programs. Methods that could detect memory leaks during Java program execution would be particularly advantageous in continuous-operation applications such as in Web Application Servers (for example, the WebSphere product by International Business Machines Corporation), and in high-reliability environments such as telecommunications applications, where it is particularly hard to detect, isolate and remedy memory leaks.